﻿<?php
$errors         = array();  	// array to hold validation errors
$rdata 			= array(); 		// array to pass back data
require_once 'resource_language.php';
$GET_DATA_ACTION = 26; $UPDATE_DATA_ACTION = 28;

if (isset($_REQUEST['ajaxcallid'])) {
	if ((int) $_REQUEST['ajaxcallid'] == $GET_DATA_ACTION) {
		$fData = $_REQUEST['fData'];
		//get variable and create query to db
		$data=getResourceLang($fData);
		$rdata['en']=$data['en'];
		$rdata['vi']=$data['vi'];
		$returnData = json_encode($rdata);
		echo $returnData;
		die();

	}
	else if ((int) $_REQUEST['ajaxcallid'] == $UPDATE_DATA_ACTION) {
		$fData = json_decode($_REQUEST['fData'],true);
		$tempArray = array_values($fData);
		//get variable and create query to db
		$key=$tempArray[0];
		$module=$tempArray[1];
		$valvi=$tempArray[2];
		$valus=$tempArray[3];
		//update data us
		updateResourceLang($key,$valus,"en-US");			
		///update data vi
		updateResourceLang($key,$valvi,"vi-VN");
		//echo "update success";		
		echo $key;
		die();

	}
}
else {
	echo 'invalid';
	die();
}



/*
 if (isset($_REQUEST['ajaxcallid'])) {
 if ((int) $_REQUEST['ajaxcallid'] == 26) {
 $personData = json_decode($_REQUEST['fData'],true);
 $tempArray = array_values($personData);
 $returnData = json_encode($personData);
 echo $returnData;
 die();
 }
 } else {
 echo 'invalid';
 die();
 }
 */